package chat.model;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


import javax.swing.*;
import java.awt.*;
import java.io.*;

/**
 *
 * @author hoangvutrung
 */
public class displayHelp extends JFrame {
    
    private JTextArea content = new JTextArea(32,15);
    private String dir = System.getProperty("user.dir") + "/helpContent.txt"; // get path of source folder
    
    public displayHelp()
    {
        setSize(460,580);
        this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        this.setTitle("Help Content: ");
        
        Container container = this.getContentPane();
        container.setLayout(new GridBagLayout());      
        GridBagConstraints c = new GridBagConstraints();        
        c.fill = GridBagConstraints.HORIZONTAL;
        c.weightx = 0.01;      
        c.gridx = 0;
        c.gridy = 0;
        c.anchor = GridBagConstraints.CENTER;
        content.setForeground(Color.blue);
        content.setEditable(false);
        container.add(new JScrollPane(content),c);
        
        
        try{
        // Open the file that is the first 
        // command line parameter
        FileInputStream fstream = new FileInputStream(dir); 
        // Get the object of DataInputStream
        DataInputStream in = new DataInputStream(fstream);
        BufferedReader br = new BufferedReader(new InputStreamReader(in));
        String allContent = "";
        String strLine;
        //Read File Line By Line
        while ((strLine = br.readLine()) != null)   {
        // Print the content on the console

        allContent += strLine + "\n\r";

        }
        content.setText(allContent);
        //Close the input stream
        in.close();
            }catch (Exception e){//Catch exception if any
        System.err.println("Error: " + e.getMessage());
        }
        
    }
    
    
}
